package findString;

public class Solution {
    public int findString(String[] words, String s) {
        // 就是跳过空的字符串
        int l = 0,r = words.length-1;
        while (l<=r){
            while (l<=r&&words[l].length()==0){
                l++;
            }
            while (l<=r&&words[r].length()==0){
                r--;
            }
            if(l<=r){
                int mid = (l+r)/2;
                while (mid<=r&&words[mid].length()==0){
                    mid++;
                }
                if(words[mid].compareTo(s) == 0) {
                    return mid;
                } else if (words[mid].compareTo(s)>0) {
                    r = mid-1;
                } else {
                    l = mid+1;
                }
            }
        }
        return -1;
    }
}
